Cube stage;                       //declare instance of Cube building
float bounds = 300;
float r = 88;
float x;
float y;
float z;
float xSpeed;
float ySpeed;
float zSpeed;
int m = 1;
float xvectorCoord1;
float xvectorCoord2;
float yvectorCoord1;
float yvectorCoord2;
void setup(){
//  size (640, 360, P3D);
  stage = new Cube(bounds, bounds, bounds);
  xSpeed = random(-3,3);
  ySpeed = random(-3,3);
  zSpeed = random(-3,3);
/*  addMouseWheelListener(new MouseWheelListener() { 
    public void mouseWheelMoved(MouseWheelEvent mwe) { 
      mouseWheel(mwe.getWheelRotation());
  }}); */
} 
String sketchRenderer(){
  return P3D;
}
void mouseWheel(int delta) {
  zSpeed += delta;
 }
void draw(){
  background (250);
  lights();
  noFill();
  translate(width/2, height/2, -130);
  stage.create();
  translate(x, y, z);           
  x += xSpeed;
  y += ySpeed;
  z += zSpeed;
  fill (255,255,0);
  sphere (r);
  if (x > ((bounds/2)-r) || x < ((-bounds/2)+r)){
      xSpeed*=-1;
    }
  if (y > ((bounds/2)-r) || y < ((-bounds/2)+r)){
      ySpeed*=-1;
    }
  if (z > ((bounds/2)-r) || z < ((-bounds/2)+r)){
      zSpeed*=-1;
    }
}

void mousePressed (){
  xvectorCoord1 = mouseX;
  yvectorCoord1 = mouseY;
}

void mouseReleased (){
  xvectorCoord2 = mouseX;
  yvectorCoord2 = mouseY;
  xSpeed = (xvectorCoord2 - xvectorCoord1)/10;
  ySpeed = (yvectorCoord2 - yvectorCoord1)/10;
  if (xSpeed < 0.5 && xSpeed > -0.5){
    xSpeed = 0;
  }
  if (ySpeed < 0.5 && ySpeed > -0.5){
    ySpeed = 0;
  }
  if (xSpeed < 0.5 && xSpeed > -0.5 && ySpeed < 0.5 && ySpeed > -0.5) {
    zSpeed = 0;
  }
}
